package com.hirsi.common.core.exception;

import lombok.Getter;
import org.springframework.http.HttpStatus;

@Getter
public class ServerRuntimeException extends RuntimeException {

    private HttpStatus status;

    private Integer code;

    private Object data;

    public ServerRuntimeException() {
        super("服务器错误，请稍后重试");
        status = HttpStatus.INTERNAL_SERVER_ERROR;
        code = 500;
    }

    public ServerRuntimeException(String msg) {
        super(msg);
        status = HttpStatus.BAD_REQUEST;
        code = 400;
    }

    public ServerRuntimeException(IExceptionEnum exceptionEnum) {
        super(exceptionEnum.getMsg());
        this.status = exceptionEnum.getStatus();
        this.code = exceptionEnum.getCode();
        this.data = exceptionEnum.getData();
    }

    public ServerRuntimeException(IExceptionEnum exceptionEnum, Object data) {
        super(exceptionEnum.getMsg());
        this.status = exceptionEnum.getStatus();
        this.code = exceptionEnum.getCode();
        this.data = data;
    }

    public ServerRuntimeException(HttpStatus status, Integer code, String s) {
        super(s);
        this.status = status;
        this.code = code;
    }

    public ServerRuntimeException(HttpStatus status, Integer code, String s, Throwable throwable) {
        super(s, throwable);
        this.status = status;
        this.code = code;
    }

    public ServerRuntimeException(String s, HttpStatus status, Integer code, Object data) {
        super(s);
        this.status = status;
        this.code = code;
        this.data = data;
    }

    public ServerRuntimeException(HttpStatus status, Integer code, String s, Throwable throwable, Object data) {
        super(s, throwable);
        this.status = status;
        this.code = code;
        this.data = data;
    }
}
